﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Maticsoft.Common;
using LTP.Accounts.Bus;
namespace MidSoft.Sys.Organize
{
    public partial class Add : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";
            if (this.txtOrganizeName.Text.Trim().Length == 0)
            {
                strErr += "组织（公司名称）不能为空！\\n";
            }
            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            string OrganizeName = this.txtOrganizeName.Text;
            DateTime CreateTime = DateTime.Now;
            int CreateUserId = 0;
            if (Session["currentUserID"] != null && Session["currentUserID"].ToString() != "")
                CreateUserId = ChinaSoft.Common.Input.SetInt(Session["currentUserID"]);

            #region 添加
            ChinaSoft.Model.Model_tb_MidSoft_Organize model = new ChinaSoft.Model.Model_tb_MidSoft_Organize();
            model.OrganizeName = OrganizeName;
            model.CreateTime = CreateTime;
            model.CreateUserId = CreateUserId;

            ChinaSoft.BLL.BLL_tb_MidSoft_Organize bll = new ChinaSoft.BLL.BLL_tb_MidSoft_Organize();
            int OrganizeId=bll.Add(model);
            #endregion
            #region 添加日志
            ChinaSoft.Model.Model_tb_MidSoft_log modelLog = new ChinaSoft.Model.Model_tb_MidSoft_log();
            ChinaSoft.BLL.BLL_tb_MidSoft_log bllLog = new ChinaSoft.BLL.BLL_tb_MidSoft_log();
            modelLog.userAccount = "";
            if (Session["UserAccount"] != null && Session["UserAccount"].ToString() != "")
                modelLog.userAccount = Session["UserAccount"].ToString();
            modelLog.userName = "";
            if (Session["UserName"] != null && Session["UserName"].ToString() != "")
                modelLog.userName = Session["UserName"].ToString();
            modelLog.description = "组织机构信息添加,ID=" + OrganizeId + ",OrganizeName=" + OrganizeName;
            modelLog.LogType = 1;
            modelLog.CreateTime = DateTime.Now;
            bllLog.Add(modelLog);
            #endregion
            Response.Write("<script>alert('成功！');top.window.parent.frames.item('workspace').location.reload();window.parent.$('#DivSysiframe').dialog(\"close\");</script>");
        }
    }
}